package com.example.demo.Spire.DocForJava;

import com.spire.doc.Document;
import com.spire.doc.PageSetup;
import com.spire.doc.Section;
import com.spire.doc.documents.Paragraph;
import com.spire.doc.documents.TextWrappingStyle;
import com.spire.doc.fields.DocPicture;
import sun.plugin.javascript.navig.Image;

public class Test {

    public static void main(String[] args)throws Exception {
        Document doc = new Document("D:\\xrb.docx");
        Paragraph paragraph = doc.createParagraph();
        Section section = doc.getLastSection();
        PageSetup pageSetup = section.getPageSetup();
        //获取页面宽度
        float pageWidth = (float)pageSetup.getPageSize().getWidth();
        //获取左右页边距宽度
        float left = pageSetup.getMargins().getLeft();
        float right = pageSetup.getMargins().getRight();
        //可编辑区域的宽度，此宽度既可以作为插入图片的宽度，刚好铺满
        float width = pageWidth - left - right;

        //设置图片大小代码
        paragraph = section.addParagraph();
        DocPicture picture = paragraph.appendPicture("D:\\head.png");
        picture.setWidth(100f);
        picture.setHeight(100f);
    }
}
